﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;

namespace BasePlatformAgent
{
	class Program
	{
		static void Main(string[] args)
		{
			Process currentProcess = Process.GetCurrentProcess();
			int currentPID = currentProcess.Id;
			try
			{
				var processes = Process.GetProcessesByName("BasePlatformAgent");
				if (processes.Length > 0)
				{
					foreach(Process p in processes)
					{
						if(p.Id != currentPID)
						{
							p.Kill();
						}
					}
				}

				if (args != null && args.Length > 0)
				{
					AgentCore core = new AgentCore(args[0]);
				}
				else
				{
					AgentCore core = new AgentCore();
				}

				Console.WriteLine("[Program] currentPID = " + currentPID);
			}
			catch (Exception ex)
			{
				Console.WriteLine(ex.Message + ex.StackTrace);
			}
		}
	}
}
